#
# ckcore/Makefile
#
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies. Remember to do have actions
# for "archclean" for cleaning up for this architecture
#
# This file is subject to the terms and conditions of the GNU General Public
# License.  See the file "COPYING" in the main directory of this archive
# for more details.
#
# (C) Copyright 2004, Li Chunqiang (chunqiang_li@c-sky.com)
# (C) Copyright 2009, Hu Junshan (junshan_hu@c-sky.com)
# (C) Copyright 2009, C-SKY Microsystems Co., Ltd. (www.c-sky.com)
#

#
# To select default config enrty. If you want to use default config, you can 
#   enter "make defconfig".
#
KBUILD_DEFCONFIG := ckcore_defconfig

OBJCOPYFLAGS    :=-O binary
GZFLAGS     :=-9

ifdef CONFIG_CPU_HAS_DSP
CPUTYPE = -mcpu=ck610ef
else
CPUTYPE = -mcpu=ck610f
endif

KBUILD_CFLAGS += -fsigned-char -g \
                 $(KBUILD_CFLAGS) -I$(INCGCC) \
                -pipe -DNO_FPU -D__ELF__ -DMAGIC_ROM_PTR \
                -DUTS_SYSNAME=\"linux\" -D__linux__ \
                -DNO_TEXT_SECTIONS $(CPUTYPE) 

machine-$(CONFIG_CK6408EVB) := ck6408evb

machine-$(CONFIG_GX3XXX) := gx3xxx

machdirs := $(patsubst %,arch/ckcore/%/,$(machine-y))

ifeq ($(KBUILD_SRC),)
KBUILD_CFLAGS += $(patsubst %,-I%include,$(machdirs))
else
KBUILD_CFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
endif

ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
KBUILD_CPPFLAGS += -mbig-endian
LDFLAGS += -EB
else
KBUILD_CPPFLAGS += -mlittle-endian
LDFLAGS += -EL
endif

KBUILD_AFLAGS += $(KBUILD_CFLAGS)

head-y := arch/ckcore/kernel/head.o

core-y                      += arch/ckcore/kernel/    arch/ckcore/mm/
core-y                      += $(machdirs)
libs-y                      += arch/ckcore/lib/ 

CLEAN_FILES += \
    arch/$(ARCH)/include/asm/asm-offsets.h \
    arch/$(ARCH)/kernel/asm-offsets.s \

all: zImage

boot := arch/ckcore/boot

zImage Image bootpImage uImage: vmlinux
	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@

bootstrap:
	$(Q)$(MAKEBOOT) bootstrap

install:
	$(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install

archmrproper:

archclean:
	$(Q)$(MAKE) $(clean)=$(boot)

define archhelp
  echo  '* zImage       - Compressed kernel image (arch/$(ARCH)/boot/zImage)'
  echo  '  Image        - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
  echo  '  uImage       - U-Boot wrapped zImage'
endef

